<?php

if (!isset($newspage)) {
    $newspage=1;
}

$nlist = new Led_Entity_Collection(0, 36, $this->app->getLangid(), 2, 0, 50);
$news = new Led_Entity_Collection (0, 15, $langid, 2, $this->entity->newslist, 50);

if (!$news->entities) {
    $sizedoesmatter=0;
} else {
    if ($news->size < ($this->entity->newsperpage * $newspage)) {
        $sizedoesmatter = $news->size;
    } else {
        $sizedoesmatter = ($this->entity->newsperpage * $newspage);
    }
}

if ($this->entity->newslist) {

    print "<div class=\"news_full\">\n";


    if (!isset($_GET['newspage'])) {
        $newspage = 1;
    } else {
        $newspage = $_GET['newspage'];
    }

    $totalnews = $news->count();
    $totalpages = (int) ($totalnews / $this->entity->newsperpage);
    if ($totalnews % $this->entity->newsperpage > 0) {
        $totalpages = $totalpages + 1;
    }

    $this->entity->newspagebox($newspage, $totalpages);

    $news->slice($this->entity->newsperpage * ($newspage-1), $this->entity->newsperpage);
    

    foreach($news as $news2) {
    
   // $news_slice = array_slice ($news->entities, , );      
    // for ($counter = ($this->entity->newsperpage * ($newspage-1) + 1); $counter <= $sizedoesmatter; $counter++) {
// $news2 = current($news_slice);
print "<div class=\"newsbox\">\n";
print "\n<a name=\"news" . $news2->id . "\"></a>";

if ($version == "pretail") {
$news2->Window_PretailBox("pleft");
}

print "<div class=\"info\">\n";
print date($this->entity->dateformat, $news2->date_created);

print" -- ";

if ($this->entity->showheader) {
print $news2->headerr;
}

print "</div>\n";
print "<div class=\"content\">\n";			

if ($this->entity->showshort) {
print "<div class=\"shortversion\">\n";
print $news2->shortnew;
print "</div>\n";
}

if ($this->entity->showfull) {
print "<div class=\"fullversion\">\n";

$coll = new Led_Entity_Collection(0, null, $this->app->getLangid(), 2, $news2->id, 50);
print $coll->render();

if ($this->entity->showposter) {
    $theposter = $this->app->getEdo()->fetch($news2->poster);
    if ($theposter) {
        print "<div class=\"poster\">\n";
        print $theposter->fullname;
        print"</div>\n";
    }
}
print "</div>\n";
}


print "<div style=\"clear: both;\"></div>\n";

print "</div>\n";
print "</div>\n";


// next($news_slice);




}
$this->entity->newspagebox($newspage, $totalpages);


print "</div>";

}